#include "stm32f0xx.h"

#define CPU_FREQ_MHZ 48

//使用内置RC
void RCC_Configuration(void) 
{ 
	RCC_HSEConfig(RCC_HSE_OFF);	
	RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_12); 
	RCC_PLLCmd(ENABLE);  
	while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)     
	{     
	}       
	RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);  
	while(RCC_GetSYSCLKSource() != 0x08)
	{
	}
}

void cpu_os_init(void)
{
	RCC_Configuration();
}

void cpu_os_start(void)
{	
	NVIC_InitTypeDef NVIC_InitStructure;
	SysTick_Config(CPU_FREQ_MHZ*1000);

	NVIC_InitStructure.NVIC_IRQChannel = PendSV_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPriority = 3;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;	
	NVIC_Init(&NVIC_InitStructure);

	NVIC_InitStructure.NVIC_IRQChannel = SysTick_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPriority = 3;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;	
	NVIC_Init(&NVIC_InitStructure);
}

void cpu_os_idle(void)
{
	
}
